package com.example.taximeter.mapper;

import com.example.taximeter.bean.Price;
import com.example.taximeter.bean.TaximeterType;
import com.example.taximeter.bean.TaximeterTypeView;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 计价器型号
 */
@Mapper
public interface TaximeterTypeMapper {

    //查询计价器型号列表
    @Select("select id , jjq_type, memo from tab_dict_jjq_type")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "memo", column = "memo")
    })
    List<TaximeterType> findTaximeterTypeList();

    //查询计价器类型(计价器类型)
    @Select("select id , jjq_type ,fact_id from tab_dict_jjq_type where jjq_type = #{jjqtype,jdbcType=VARCHAR} ")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "factid", column = "fact_id"),
            @Result(property = "jjqtype", column = "jjq_type")
    })
    List<TaximeterType> findTaximeterTypeByTaximeterType(@Param("jjqtype") String jjqtype);

    //新增计价器类型
    @Insert("insert into tab_dict_jjq_type (jjq_type,memo,fact_id)\n" +
            "    values (#{jjqtype,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}, #{factid,jdbcType=INTEGER}) ")
    Boolean addTaximeterType(TaximeterType taximeterType);

    //修改计价器类型
    @Update("update tab_dict_jjq_type set jjq_type = #{jjqtype,jdbcType=VARCHAR},memo = #{memo,jdbcType=VARCHAR} ,fact_id = #{factid,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}")
    boolean updateTaximeterType(TaximeterTypeView taximeterTypeView);


    //删除计价器类型
    @Delete("delete from tab_dict_jjq_type  where id = #{id,jdbcType=INTEGER}")
    boolean deleteTaximeterType(Integer id);

    //查询计价器类型列表
    @SelectProvider(type = ActivityMapperProvider.class, method = "findTaximeterTypeAll")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "memo", column = "memo"),
            @Result(property = "factid", column = "fact_id"),
            @Result(property = "factname", column = "fact_name")
    })
    List<TaximeterTypeView> findTaximeterTypeAll(TaximeterTypeView taximeterTypeView);

    //查询计价器型号列表(计价器厂商)
    @Select("select id , jjq_type, memo from jjqtype where fact_name = #{factname,jdbcType=VARCHAR}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "memo", column = "memo")
    })
    List<TaximeterType> findJjqByFactname(String factname);

    //查询计价器型号列表(计价器厂商)
    @Select("select id , jjq_type, memo from jjqtype where fact_id = #{factid,jdbcType=INTEGER}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "memo", column = "memo")
    })
    List<TaximeterType> findJjqByFactid(Integer factid);

    //查询计价器型号列表(计价器厂商)
    @Select("select id , jjq_type, fact_id,memo from jjqtype where id = #{id,jdbcType=INTEGER}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "factid", column = "fact_id"),
            @Result(property = "memo", column = "memo")
    })
    TaximeterType findJjqById(Integer id);

    //查询计价器型号(id)
    @Select("select jjq_type from jjqtype where id = #{id,jdbcType=INTEGER} ")
    @Results({
            @Result(property = "jjqtype", column = "jjq_type")
    })
    String findJjqtypeByJjqtypeid(@Param("id") Integer id);
}
